package com.design.demo.observer;

import java.util.Observable;
import java.util.Observer;

/**
 * @author guoliang.li
 * @date 2019/12/27 17:49
 * @description TODO 消息订阅者
 */
public class Student implements Observer {

    private Observable observable;
    private String name;

    public Student(Observable observable, String name) {
        this.observable = observable;
        this.name = name;
        observable.addObserver(this);
    }

    @Override
    public void update(Observable o, Object arg) {
        Teacher t = (Teacher) o;
        System.out.println(name + "：得到的消息\t" + t.getInfo());
    }
}
